import Vue from 'vue';
import SlideVerify from 'vue-monoplasty-slide-verify';
import Cookies from 'js-cookie';
import Element from 'element-ui';
import VueAMap from '@vuemap/vue-amap';
import '@vuemap/vue-amap/dist/style.css';
//element-ui theme
import './assets/styles/element-variables.scss';
//windi css
import 'windi.css';
// global css
import '@/assets/styles/index.scss';
import App from './App';
import store from './store';
import router from './router';
import { download2, download3 } from '@/utils/request';
import permission from './directive/permission';
import { formatDate } from '@/utils';
import request from './utils/request';
import './assets/icons'; // icon
import './permission'; // permission control
import { getDicts } from '@/api/system/dict/data';
import { getConfigKey } from '@/api/system/config';
import { addDateRange, download, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels } from '@/utils/tencreat';
import tools from '@/utils/tools';
import Pagination from '@/components/Pagination';

// 自定义表格工具扩展
import RightToolbar from '@/components/RightToolbar';

// 全局组件
import ElxImgManager from '@/components/upload-image/ElxImgManager';
import ElxImgbox from '@/components/upload-image/ElxImgbox';
import ElxImgboxPlugin from '@/components/upload-image/ElxImgboxPlugin';
import Upload from '@/components/upload-image/upload';
import startEndTime from '@/components/StartEndTime';
import Api from './api/admin.js';
import VideoPlayer from 'vue-video-player';

import install from '@/components/L';
import LTableColumn from '@/components/L/Table/column';

Vue.filter('formatNumber', (value) => {
	return tools.formatNumber(value);
});

//表格非空格式化方法
Vue.prototype.emptyToString = (row, column, cellValue) => {
	return cellValue ? cellValue : '-';
};
Vue.prototype.emptyToNumber = (row, column, cellValue) => {
	return cellValue ? cellValue : 0;
};
Vue.prototype.$api = Api;
Vue.prototype.$request = request;
// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.formatDate = formatDate;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.download2 = download2;
Vue.prototype.download3 = download3;
Vue.prototype.handleTree = handleTree;

Vue.prototype.msgSuccess = function (msg) {
	this.$message({ showClose: true, message: msg, type: 'success' });
};

Vue.prototype.msgError = function (msg) {
	this.$message({ showClose: true, message: msg, type: 'error' });
};

Vue.prototype.msgInfo = function (msg) {
	this.$message.info(msg);
};

// 全局组件挂载

Vue.component('Pagination', Pagination);
Vue.component('RightToolbar', RightToolbar);
Vue.component('StartEndTime', startEndTime);

Vue.component('LTableColumn', LTableColumn);

// 自动启用插件
Vue.use(ElxImgboxPlugin);
Vue.component('ImageManager', ElxImgManager);
Vue.component('ImageUpload', ElxImgbox);
Vue.component('ZUpload', Upload);

Vue.use(permission);
Vue.use(VideoPlayer);
Vue.use(SlideVerify);

Vue.use(Element, {
	size: Cookies.get('size') || 'medium',
});
Vue.use(install);

//高德地图
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
	key: 'a24f9116f57a3eef55f151a9564af789',
	plugins: ['AMap.Scale', 'AMap.Geolocation', 'AMap.ToolBar', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.MapType', 'AMap.Geocoder'],
	version: '2.0',
});

window._AMapSecurityConfig = {
	securityJsCode: '54a5fd3dcbe863ae29a6fc91f794bb63',
};

Vue.config.productionTip = false;

new Vue({
	el: '#app',
	router,
	store,
	render: (h) => h(App),
});
